<!DOCTYPE html>
<html>
	<head>
	    <meta charset="utf-8">
	    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
	    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
	    <title>Hello APP</title>
	    <link rel="stylesheet" type="text/css" href="../../../css/index.css" />
	</head>
	<style type="text/css">
		.warp{width: 100%;}

		/*类型切换*/
		.num-box{width: 100%;padding: 0 15px 65px 15px;background:#FF9502;color: #ffffff;box-sizing: border-box;}
		.sel-type{width: 100%;height: 46px;}
		.sel-type.fixed-sta{position: fixed;top: 0;}
		.sel-type .type-one{height: 100%;text-align: center;line-height: 46px;font-size: 15px;color: #ffffff}
		.sel-type .type-one.on{position: relative;font-weight: bold;}
		.sel-type .type-one.on:after{display: block;content:"";width: 16px;height: 3px;background: #ffffff;position: absolute;bottom: 0;left: 50%;margin-left: -8px;}

		/*统计*/
		.tongji{margin: -45px 15px 0 15px;background: #ffffff;border-radius: 4px;height: 90px;align-items: center;}
		.tongji .tongji-one{flex-direction: column;justify-content: center;align-items: center;}
		.tongji .tongji-one .num{font-size: 14px;color: #FF9502;font-weight: bold;}
		.tongji .tongji-one .num i{font-size: 24px;}
		.tongji .tongji-one .t{font-size: 14px;color: #333333;padding-top: 6px;}
		.tongji .ge{height: 50px;}
		.tongji .ge::before{background: #FF9502;}

		/*时间选择*/
		.date{width: 100%;padding: 10px 15px 0 15px;box-sizing: border-box;}
		.date .day{height: 40px;width: auto;line-height: 40px;font-size: 14px;display: inline-block;}
		.date .sel-date{height: 40px;width: auto;line-height: 40px;font-size: 14px;display: inline-block;padding-right: 20px;
		background: url(../../../image/main3/store/down.png) no-repeat right 10px center;background-size: 6px 4px;}

		.info-list{width: 100%;}
		.info-list .info-one{width: 100%;padding: 0 15px;box-sizing: border-box;align-items: center;background: #FFFFFF;height: 70px;}
		.info-list .info-one .l .t1{font-size: 15px;color: #333333;font-weight: 500;}
		.info-list .info-one .l .t2{font-size: 12px;color: #999999;padding-top: 8px;}
		.info-list .info-one .r .t3{font-size: 15px;color: #FF9502;text-align: right;font-weight: bold;}
		.info-list .info-one .r .t4{font-size: 12px;color: #999999;text-align: right;padding-top: 8px;}
		.info-list .info-one:last-child:before{display: none;}

	</style>
	<body>
		<div id="vue" class="warp">

			<div class="num-box">
				<div class="sel-type flex">
					<div :class="['type-one flex1', tj_type == 0 ? 'on':'']" tapmode onclick="tab_type(this);" data-sta="0">今日分润</div>
					<div :class="['type-one flex1', tj_type == 1 ? 'on':'']" tapmode onclick="tab_type(this);" data-sta="1">累计分润</div>
				</div>
			</div>

			<div class="tongji flex">
				<div class="tongji-one flex flex1">
					<div class="num"><i v-text="XiaoData.sale_price"></i>元</div>
					<div class="t"><i v-show="tj_type == 0">今日分润</i><i v-show="tj_type == 1">累计分润</i></div>
				</div>
				<div class="ge border-right"></div>
				<div class="tongji-one flex flex1">
					<div class="num"><i v-text="XiaoData.sale_onum"></i>单</div>
					<div class="t">订单数量</div>
				</div>
			</div>

			<div class="date">
				<div id="dayTime" class="day" v-show="tj_type == 0" v-text="XiaoData.time"></div>
				<div id="selTime" class="sel-date" v-show="tj_type == 1" v-text="XiaoData.time" tapmode onclick="sel_time(this)"></div>
			</div>

			<div class="info-list" style="display:none;" :style="{ display:(Pdata ? '':'none')}">
				<div class="info-one flex border-bottom" v-for="(item,key) in Pdata.listData">
					<div class="l flex1">
						<div class="t1" v-text="item.note"></div>
						<div class="t2" v-text="item.addtime"></div>
					</div>
					<div class="r">
						<div class="t3" ><i v-if="item.type == 'del'">-</i><i v-if="item.type == 'add'">+</i><i v-text="item.value"></i></div>
						<div class="t4" >积分:<i v-text="item.new_val"></i></div>
					</div>
				</div>
			</div>

			<!--占位图-->
			<div class="nodata" style="display:none;" :style="{ display:(noData ? '':'none')}">
				<img src="../../../image/no_page/no_jilu.png" />
				<p>暂无记录</p>
			</div>

			<!-- 底部 -->
			<div class="bottom-box" :style="{ display:(loadingMsg ? '':'none')}">
				<div class="msgbox" v-html="loadingMsg" style="color:#999;"></div>
			</div>

		</div>
	</body>
</html>
<script type="text/javascript" src="../../../script/base.min.js" id="loadjs" data-js="L/swiper.min,L/lazyload,L/h-tool"></script>
<script type="text/javascript">
	define(function (require, exports, module) {

		var timeDate = lanYun.getStorage('newDate');
		var ptime = '';
		var ztime = '';
		var sta = 0;

		// 初始化当天日期
		// setTime = function () {
		// 	$("#dayTime").text(timeDate.t2);
		// 	ptime = timeDate.t1;
		// 	ztime = timeDate.t2;
		// }

		// 选择日期
		// setTime0 = function () {
		// 	$("#selTime").text(timeDate.t4);
		// 	ptime = timeDate.t3;
		// 	ztime = timeDate.t4;
		// }

		// 获取销售信息
		getXiaoShou = function functionName() {
			var getUrl = '';
			if(sta == 0){
				getUrl = 'company/Fenrun/today_fenrun';
			}else {
				getUrl = 'company/Fenrun/old_fenrun';
			}
			lanYun.get(getUrl,function (ret){
				//console.log(JSON.stringify(ret));
				if (ret.errcode == 0) {
					lanYun.vue.XiaoData = ret.data;
					ptime = ret.data.searchTime;
					if(sta == 0){ptime = '';}
					_page.getData(2);
				}else {
					lanYun.toast(ret.msg);
				}
			},2);
		}

		_page.getData = function(loading) {
			lanYun.getVueData({url:'company/Fenrun/loglist',get:{page:lanYun.page,time:ptime},cache:0,loading:loading},function(ret) {
				//console.log(JSON.stringify(ret));
			});
		};

		lanYun.newVue('#vue',{
			tj_type:0,
			XiaoData:{}
		},function() {
			getXiaoShou();
		});

		//滚动加载..
		new auiScroll({distance:200, listen:true},function(ret) {
			if($(window).scrollTop() < 2) ret.isToBottom = false;
			var d = ret.scrollTop / 208;
			if(!ret.isToBottom) return;
			_page.getData(0);
		});

		//切换头部类型
		tab_type = function (tis) {
			if($(tis).hasClass('on')) return;
			var dst = tis.dataset;
			var index = $(tis).index();
			// $('.sel-type .type-one').removeClass('on');
			// $(tis).addClass('on');
			sta = dst.sta;
			// if(sta == 0){
			// 	setTime();
			// }else {
			// 	setTime0();
			// }
			lanYun.vue.tj_type = sta;
			setData();
		}

		// 选择时间
		sel_time = function () {
			lanYun.actionSelect({
				col:2,
				cachekey:'time',
				title:'选择时间',
				successCall:function(result){
					if(result && result.eventType == 'ok' && result.selectedInfo){
						//ztime = result.level1 + result.level2 +  result.level3;
						ztime = result.level1 + result.level2;
						$('#selTime').text(ztime);
						var data = [];
						$.each(result.selectedInfo, function(k,v){
							//data.push(v.name0);
							if(k<2){
								data.push(v.name0);
							}
						});
						ptime = data.join("-");
						ptime = ptime + '-01';

						// 只刷新列表
						lanYun.ajaxPageSta = 0; lanYun.page = 1;
						_page.getData(2);
					}
				}
			});
		}

		// 刷新列表
		setData = function () {
			lanYun.ajaxPageSta = 0; lanYun.page = 1;
			getXiaoShou();
		}

	});
</script>
